/**
 * 
 */
package com.mc.okhttp;

import java.io.IOException;
import java.util.concurrent.TimeUnit;

import com.alibaba.fastjson.JSONObject;

import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

/**
 * @author w.weizhen
 *
 */
public class Test {
    
    /**
     * @param args
     */
    public static void main(String[] args) 
    {
    	JSONObject data = new JSONObject();
    	data.put("id", "22");
    	//监督记录ID
    	data.put("hiId", "156");
    	//处罚类型 1警告;2罚款
    	data.put("punishType", "2");
    	//违法行为
    	data.put("illegal", "x对公路客运车辆载客超过核定乘员、货运机动车超过核定载质量的");
    	//违反法律条款
    	data.put("stipulation", "x第二十九条 对公路客运车辆载客超过核定乘员、货运机动车超过核定载质量的");
    	//依据法律条款规定
    	data.put("clause", "x一是针对医疗保障经办机构，区分不同的违法行为，规定了责令改正、责令退回、处以罚款");
    	//罚款
    	data.put("fine", "10");
    	//大于零为限期整改,不大于一为立即整改
    	data.put("limitDay", "15");
    	//罚款缴纳地址
    	data.put("paymentAddress", "x江苏省南京市雨花台区七贤街16-1号贾西地铁2号线出口对面");
    	//政府机关名称
    	data.put("government", "x七彩星城幼儿园");
    	//法院名称
    	data.put("court", "x江苏国家安全教育馆");
    	System.out.println(data.toJSONString());
    	String url = "https://njpk.hynetic.cn/trtc/hi_punish/update.hynetic";
    	String result = null;
        OkHttpClient httpClient = new OkHttpClient();
        MediaType contentType = null;
        //contentType = MediaType.parse("text/html;charset=utf-8");
        contentType = MediaType.parse("application/json; charset=utf-8");
        RequestBody requestBody = RequestBody.create(contentType, data.toJSONString());
        Request request = new Request.Builder().url(url).post(requestBody).build();
        try {
            Response response = httpClient.newCall(request).execute();
            result = response.body().string();
            System.out.println(result);
        } catch (IOException e) {
            e.printStackTrace();
        }
    	
    }
    
}